<% layout('/layout/default.html', {title: '机构管理', libs: ['validate','icheck']}){ %>
<div class="main-content">
	<div class="container-fluid">
		<div class="card-header">
			<div class="box-title">
				<i class="fa fa-sitemap"></i>${office.isNewRecord?'添加机构':'修改机构信息'}
			</div>
		</div>
		<#form:form id="inputForm" model="${office}" class="form-horizontal" action="${ctx}/sys/office/save" method="post">
		<div class="card-body">
			<#form:hidden path="id"/>
			<div class="row">
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="上级区域">
							上级机构:
						</label>
						<div class="col-sm-8 col-md-8">
							<div class="form-control form-control-sm" readonly="readonly">
								<#form:hidden path="parent.id"/>
								<% if(office.parent.id == "0") {%>
								根机构
								<% } else{ %>
								${office.parent.name}
								<% } %>
							</div>
						</div>
					</div>
				</div>
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="归属区域">
							<span  style="color:red;" aria-required="true">*</span>归属区域:<i class="fa icon-question hide"></i>
						</label>
						<div class="col-sm-8">
							<#form:treeselect id="area" name="office.area.name" value="${office.area.id!}" labelName="office.area.name" labelValue="${office.area.name!}"
							title="归属区域" url="/sys/area/treeData?type=3" cssClass="form-control-sm required" allowClear="true" notAllowSelectParent="false"/>
						</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="机构名称">
							<span  style="color:red;" aria-required="true">*</span> 机构名称:<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="name" maxlength="64" class="form-control form-control-sm required" />
						</div>
					</div>
				</div>
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="机构编码">
							机构编码：
						</label>
						<div class="col-sm-8">
							<#form:input path="code"  maxlength="64" class="form-control form-control-sm" />
						</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
					<div class="form-group row">
						<label class="col-form-label col-lg-4 col-md-4 text-right" title="机构类型">
							<span  style="color:red;" aria-required="true">*</span> 机构类型:<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="type" name="label" data="getDictList:sys_office_type" class="form-control select2bs4 required">
						</#form:select>
					</div>
				</div>
			</div>
			<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
				<div class="form-group row">
					<label class="col-form-label col-lg-4 col-md-4 text-right" title="机构级别">
						<span  style="color:red;" aria-required="true">*</span> 机构级别:<i class="fa icon-question hide"></i>
					</label>
					<div class="col-sm-8">
						<#form:select path="grade" name="label" data="getDictList:sys_office_grade" class="form-control select2bs4 required">
					</#form:select>
				</div>
			</div>
		</div>
	</div>

	<div class="row">
		<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
			<div class="form-group row">
				<label class="col-form-label col-lg-4 col-md-4 text-right" title="主负责人">
					主负责人:</label>
				<div class="col-sm-8">
					<#form:treeselect id="primaryPerson" name="primaryPerson" value="${office.primaryPerson.id!}" labelName="office.primaryPerson.name" labelValue="${office.primaryPerson.name!}"
					title="主负责人" url="/sys/office/treeData?type=3"  allowClear="true" notAllowSelectParent="true" cssClass="form-control-sm"/>
				</div>
			</div>
		</div>
		<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
			<div class="form-group row">
				<label class="col-form-label col-lg-4 col-md-4 text-right" title="副负责人">
					副负责人:
				</label>
				<div class="col-sm-8">
					<#form:treeselect id="deputyPerson" name="deputyPerson" value="${office.deputyPerson.id!}" labelName="office.deputyPerson.name" labelValue="${office.deputyPerson.name!}"
					title="副负责人" url="/sys/office/treeData?type=3" allowClear="true" notAllowSelectParent="true" cssClass="form-control-sm"/>
				</div>
			</div>
		</div>
	</div>

	<div class="row">
		<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
			<div class="form-group row">
				<label class="col-form-label col-lg-4 col-md-4 text-right" title=" 联系地址">
					联系地址:</label>
				<div class="col-sm-8">
					<#form:input path="address" class="form-control form-control-sm" maxlength="50" />
				</div>
			</div>
		</div>
		<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
			<div class="form-group row">
				<label class="col-form-label col-lg-4 col-md-4 text-right" title="邮政编码">
					邮政编码:
				</label>
				<div class="col-sm-8">
					<#form:input path="zipCode" class="form-control form-control-sm" maxlength="50" />
				</div>
			</div>
		</div>
	</div>

	<div class="row">
		<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
			<div class="form-group row">
				<label class="col-form-label col-lg-4 col-md-4 text-right" title="负责人">
					负责人:</label>
				<div class="col-sm-8">
					<#form:input path="master" class="form-control form-control-sm" maxlength="50" />
				</div>
			</div>
		</div>
		<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
			<div class="form-group row">
				<label class="col-form-label col-lg-4 col-md-4 text-right" title="电话">
					电话:
				</label>
				<div class="col-sm-8">
					<#form:input path="phone" class="form-control form-control-sm" maxlength="50" />
				</div>
			</div>
		</div>
	</div>

	<div class="row">
		<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
			<div class="form-group row">
				<label class="col-form-label col-lg-4 col-md-4 text-right" title="传真">
					传真:</label>
				<div class="col-sm-8">
					<#form:input path="fax" class="form-control form-control-sm" maxlength="50" />
				</div>
			</div>
		</div>
		<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
			<div class="form-group row">
				<label class="col-form-label col-lg-4 col-md-4 text-right" title="邮箱">
					邮箱:
				</label>
				<div class="col-sm-8">
					<#form:input path="email" class="form-control form-control-sm" maxlength="50" />
				</div>
			</div>
		</div>
	</div>

	<div class="row">
		<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
			<div class="form-group row">
				<label class="col-form-label col-lg-4 col-md-4 text-right" title="是否可用">
					<span  style="color:red;" aria-required="true">*</span>是否可用:<i class="fa icon-question hide"></i>
				</label>
				<div class="col-sm-8">
					<#form:select path="useable" name="label" data="getDictList:yes_no" class="form-control select2bs4 required">
				</#form:select>
			</div>
		</div>
	</div>

	<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
		<div class="form-group row">
			<label class="col-form-label col-lg-4 col-md-4 text-right" title="排序">
				<span  style="color:red;" aria-required="true">*</span> 排序:<i class="fa icon-question hide"></i></label>
			<div class="col-sm-8">
				<#form:input path="sort" class="form-control form-control-sm required" maxlength="50" />
			</div>
		</div>
	</div>
</div>
<div class="row">
	<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
		<div class="form-group row">
			<label class="col-form-label col-lg-4 col-md-4 text-right" title="备注信息">
				备注：<i class="fa icon-question hide"></i>
			</label>
			<div class="col-sm-8">
				<#form:textarea path="remarks" rows="3" cols="32"  class="form-control" />
			</div>
		</div>
	</div>
</div>
</div>

<div class="box-footer">
	<div class="row">
		<div class="offset-md-2 col-md-10">
			<% if (hasPermi('sys:office:edit')){ %>
			<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> 保 存</button>
			<% } %>
			<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="window.parent.closeCurrentTabPage();"><i class="fa fa-reply-all"></i> 关 闭</button>
		</div>
	</div>
</div>
</#form:form>
</div>
</div>
<% } %>
<script>
	$("#inputForm").validate({
		submitHandler: function(form){
			js.ajaxSubmitForm($(form), function(data){
				js.showMessage(data.message);
				console.log(data.message);
				if(data.result == 'true'){
					window.parent.closeCurrentTabPage(window.parent.refreshTab);
				}
			});
		}
	});
</script>